package com.andyage.admin.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.andyage.admin.bean.ActivityBean;
import com.andyage.admin.dao.ActivityMapper;
import com.andyage.admin.service.IActivityService;
import com.andyage.util.JsonContent;

import net.sf.json.JSONObject;
@Service
public class ActivityServiceImpl implements IActivityService {
	@Resource
	private ActivityMapper acruvityMapper;
	@Override
	public String queryActivityInfo(ActivityBean activity) throws Exception{
		List<ActivityBean> list = acruvityMapper.queryActivityInfo(activity);
		int total = acruvityMapper.queryActivityInfoCount(activity);
		String json = JsonContent.getJsonArray(list, total);
		return json;
	}

	@Override
	public String updateActivityPublish(ActivityBean activity)throws Exception {
		int result = acruvityMapper.updateActivityPublish(activity);
		JSONObject json = new JSONObject();
		if(result!=0){
			json.accumulate("result", 1);
			json.accumulate("tips", "活动更改成功");
		}else{
			json.accumulate("result", 0);
			json.accumulate("tips", "活动更改失败");
		}
		return json.toString();
	}

}
